package com.jcl.recruit.apply.mapper;

import com.jcl.recruit.apply.model.Interview;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author 刘明新
 * @date 2018/8/6 下午5:48
 */
public interface InterviewMapper {

    @Select({
            "select * from interview where id = #{id}"
    })
    Map<String,Object> selectPrimaryKeyById(@Param("id") Integer id);

    @Select({
            "<script>",
            "select a.*,b.realname from interview a left join resume b on a.resume_id = b.id",
            "<if test=\"status != null\">where a.status = #{status}</if>",
            "order by id desc",
            "</script>"
    })
    List<Map<String,Object>> selectAllInterviews(@Param("status") Integer status);

    @Select({
            "select * from interview where resume_id = #{resumeId}"
    })
    Interview selectCountByResumeId(@Param("resumeId") Integer resumeId);

    @InsertProvider(type=InterviewSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(Interview record);

    @UpdateProvider(type=InterviewSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Interview record);

    @Select({
            "select count(*) from interview group by status order by status"
    })
    List<Integer> selectCountByStatus();
}
